<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>外观设置 - 页面管理 - <?php echo F('escape', $page['page_name']);?></title>
<link href="<?php echo W_BASE_URL;?>css/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo W_BASE_URL;?>js/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo W_BASE_URL;?>js/admin_lib.js"></script>
</head>
<body>

<?php
	// 组件类型, 2:名人推荐, 3:用户推荐 , 6:推荐话题
	$id	= $data['component_id'];
	
	// 显示数量的名称
	$num_type = '';
	switch ($id) 
	{
		case '1':
		case '5':
		case '8':
		case '9':
		case '10':
		case '12':
			$num_type = '微博';
		break;
		
		case '6':
			$num_type = '话题';
		break;
		
		default: 
			$num_type = '用户';
	}

	// 显示数量的建议
	$showNumSugg = '';
	$valids 	 = array();
	switch ($id) {
		case 2:
		case 3:
		case 1:
		case 5:
		case 6:
			$showNumSugg = '设置范围3至20之间';
			array_push($valids, 'bt=min:3,max:20,m:范围为3-20');
		break;

		default:
			$showNumSugg = '设置范围3至10之间';
			array_push($valids, 'bt=min:3,max:10,m:范围为3-10');
	}

	if (in_array($id, array(2,3,7))) {
		$showNumSugg .= ',推荐为3的倍数';
	}

	array_push($valids, 'int=m:只能输入数字');
	array_push($valids, 'ne=m:不能为空');
	
	
	// 组件显示数量
	$validsStr 		= !empty($valids) ? 'vrel='.join('|', $valids)						: '';
	$showNumSugTip 	= $showNumSugg ? '<p class="sub-tips">（'. $showNumSugg .'）</p>' 	: '';
	$showNumValue	= isset($data['param']['show_num']) ? $data['param']['show_num'] 	: '';
	$showNumHtml = '<div class="set1">
                		<div class="sub-set-l">组件显示的'. $num_type .'数量：</div>
                   		<div class="sub-set-r">
                   			<label for="number2">
                   				<input class="input-box" name="param[show_num]" type="text" '. $validsStr .' value="'. $showNumValue .'" warntip="#showNumErr"/>
                   				<span id="showNumErr" class="a-error hidden"></span>'. $showNumSugTip .'
                       		</label>
                    	</div>
                	</div>';
	
	// 微博来源
	$source			 = isset($data['param']['source']) ? $data['param']['source'] : FALSE;
	$checkSourceGet1 = $source ? ' checked="checked" ' 	: '';
	$checkSourceGet2 = !$source ? ' checked="checked" ' : '';
	$comeFromHtml = '<div class="set1">
						<div class="sub-set-l">微博来源：</div>
						<div class="sub-set-r">
							<label for="source_get1">
							<input class="radio-same" type="radio" value="1" ' .$checkSourceGet1 .' name="param[source]" id="source_get1" >仅显示来自本站微博
							</label>
							<br/>
							<label for="source_get2">
							<input class="radio-same" type="radio" value="0" '. $checkSourceGet2 .' name="param[source]" id="source_get2">显示来自新浪全局的微博
							</label>
						</div>
					</div>'
?>

<div class="main-wrap">
	<div class="path"><span class="path-icon"></span>当前位置：外观设置<span> &gt; </span>页面管理<span> &gt; </span><?php echo F('escape', $page['page_name']);?><span> &gt; </span><?php echo F('escape', $data['title']);?>组件设置</div>
    <div class="set-wrap">
		<div class="sub-set02">
        	<h4 class="main-title">设置</h4>
			<div class="set-area-int">
        		<form name="config" id="form1" action="<?php echo URL('mgr/page_manager.doEditComponent', array('page_id'=>$page_id));?>" method="post">
				<input type="hidden" name="pmId" value="<?php echo $pmId ?>" />
				<div class="set2">
					<div class="sub-set-l">组件显示的标题：</div>
					<div class="sub-set-r"><input class="input-box" type="text" vrel="ne=m:不能为空" warntip="#titleErr" name="data[title]" value="<?php echo F('escape', $data['title']) ?>"/><span class="a-error hidden" id="titleErr"></span></div>
				</div>
				
			<?php 
				if ($id == 2) { //名人推荐
					$rs 		  = DR('mgr/userRecommendCom.getById');
					$isGroupIdSet = isset($data['param']['group_id']);
					$topic_id 	  = isset($data['param']['topic_id']) ? $data['param']['topic_id'] : FALSE;
					
					// 新浪名人推荐类型
					$hotCategory = array(
						'1'  => '人气关注',
						'2'  => '影视名星',
						'3'  => '港台名人',
						'4'  => '模特',
						'5'  => '美食&健康',
						'6'  => '体育名人',
						'7'  => '商界名人',
						'8'  => 'IT互联网',
						'9'  => '歌手',
						'10' => '作家',
						'11' => '主持人',
						'12' => '媒体总编',
						'13' => '炒股高手'
					);
			?>
			
			<div class="set1">
				<div class="sub-set-l">名人列表获取方式：</div>
				<div class="sub-set-r">
					<label for="topic_get1">
						<input class="radio-same" type="radio" value="0" name="param[topic_get]" id="topic_get1" <?php if ($topic_id):?>checked<?php endif;?> onclick="javascript:$('#topicIdLabel').show(); $('#groupIdLabel').hide();" >使用新浪提供的名人推荐
					</label>
					<br />
					<label for="topic_get2">
						<input class="radio-same" type="radio"<?php if (!$topic_id):?> checked<?php endif;?> value="1" name="param[topic_get]" id="topic_get2" onclick="javascript:$('#topicIdLabel').hide(); $('#groupIdLabel').show();" >自定义名人推荐列表
					</label>
				</div>
				
				<div class="sub-set-r">
					<label id="topicIdLabel" for="topic_id" style="<?php if (!$topic_id){echo "display:none;"; } ?>">请选择推荐的类别：
						<select name="param[topic_id]" id="topic_id">
							<?php
								foreach ($hotCategory as $key => $aCate) {
									echo '<option value="'.$key.'"'. ($topic_id && $topic_id == $key ? ' selected':'') .'>' . F('escape', $aCate) . '</option>';
								}
							?>
						</select>
					</label>
						
					<label id="groupIdLabel" style="<?php if ($topic_id){echo "display:none;"; } ?>">请选组件使用的列表：
						<select name="param[group_id]">
							
							<?php
								foreach ($rs['rst'] as $row) {
									if ($row['type'] < 1) {
										echo '<option value="'.$row['group_id'].'"'. ($isGroupIdSet && $data['param']['group_id']==$row['group_id'] ? ' selected':'') .'>' . F('escape', $row['group_name']) . '</option>';
									}
								}
							?>
							
						</select>
					</label>
				</div>
				
			</div>
			
			<?php
				} elseif ($id == 3) {	// 用户推荐
					$rs 			= DR('mgr/userRecommendCom.getById');
					$isGroupIdSet 	= isset($data['param']['group_id']);
			?>
			
			<div class="set1">
				<div class="sub-set-l">使用的用户列表：</div>
				<div class="sub-set-r">
					<select name="param[group_id]">
						
					<?php
						foreach ($rs['rst'] as $row) {
							if ($row['type'] < 1) {
								echo '<option value="'.$row['group_id'].'"'. ($isGroupIdSet && $data['param']['group_id']==$row['group_id'] ? ' selected':'') .'>' . F('escape', $row['group_name']) . '</option>';
							}
						}
					?>
						
					</select>
				</div>
			</div>
			
			<?php
				} elseif ($id == 5) { //微博频道
					$group_id   = isset($data['param']['group_id']) ? $data['param']['group_id'] : 4;
					$rs		    = DR('mgr/userRecommendCom.getById', '', $group_id);
					$group_name = isset($rs['rst'][0]['group_name']) ? $rs['rst'][0]['group_name'] : '微博频道用户列表';
			?>
			
			<div class="set1">
				<div class="sub-set-l">组件使用的用户列表：</div>
				<div class="sub-set-r"><a href="<?php echo URL('mgr/user_recommend.getUserById', array('group_id' => $group_id));?>"><?php echo F('escape', $group_name);?></a></div>
			</div>
			
			<?php
				} elseif ($id == 6) { //热门话题
				 $list 		= DR('xweibo/topics.getCategoryByType');
				 $topic_get	= isset($data['param']['topic_get']) ? $data['param']['topic_get'] : 0;
				 $topic_id	= isset($data['param']['topic_id'])  ? $data['param']['topic_id']  : 0;
			?>
			
			<div class="set1">
				<div class="sub-set-l">话题获取方式：</div>
				<div class="sub-set-r">
					<label for="topic_get3">
						<input class="radio-same" type="radio" value="2" name="param[topic_get]" id="topic_get3" <?php if ($topic_get == 2){ echo ' checked '; }?> onclick="javascript:$('#topic_idLabel').hide();">站内的热门话题
					</label>
					<br />
					
					<label for="topic_get1">
						<input class="radio-same" type="radio" value="1" name="param[topic_get]" id="topic_get1" <?php if ($topic_get <=1){ echo ' checked '; }?> onclick="javascript:$('#topic_idLabel').hide();">使用新浪微博提供的热门话题
					</label>
					<br/>
					
					<label for="topic_get2">
						<input class="radio-same" type="radio" <?php if ($topic_id > 0){ echo 'checked'; }?> value="0" name="param[topic_get]" id="topic_get2" onclick="javascript:$('#topic_idLabel').show();">自定义话题列表
					</label>
					<div class="defined-topic">
						<label for="topic_id" id="topic_idLabel" <?php if($topic_id < 1) {echo " style='display:none;' ";} ?>>请选择组件使用的话题列表：
							<select name="param[topic_id]">
							
							<?php  foreach($list['rst'] as $row): if ($row['type'] < 1) {?>
								<option value="<?php echo $row['topic_id'];?>"<?php if($row['topic_id']==$topic_id):?> selected<?php endif;?>><?php echo F('escape', $row['topic_name']);?></option>
							<?php } endforeach; ?>
							
							</select>
						</label>
					</div>
				</div>
			</div>

			<?php
				} elseif ($id == 10) { //今日话题
			?>
			
				<div class="set1">
					<div class="sub-set-l">组件使用的话题列表：</div>
					<div class="sub-set-r"><a href="<?php echo URL('mgr/weibo/todayTopic.topicList', array('category'=>2));?>">今日话题列表</a></div>
				</div>
				
			<?php
				} elseif ($id == 12) { //话题微博
			?>
			
				<div class="set1">
					<div class="sub-set-l">话题：</div>
					<div class="sub-set-r"><input class="input-box" type="text" vrel="ne=m:不能为空" warntip="#titleErr" name="param[topic]" value="<?php echo F('escape', $data['param']['topic']) ?>"/><span class="a-error hidden" id="titleErr"></span></div>
				</div>

			<?php } echo $showNumHtml; ?>
			<?php if (in_array($id, array(8, 9, 10, 12))) {echo $comeFromHtml;}?>
                <div class="button"><input id="submitBtn" type="submit" value="提交" /></div>
            	</form>
    		</div>
        </div>
    </div>
</div>
<script type="text/javascript">
var valid = new Validator({
	form: '#form1'
});


</script>
</body>
</html>
